package com.weixing.mall.provider.api.service;

import com.weixing.mall.base.orm.MPage;
import com.weixing.mall.base.wrapper.Result;
import com.weixing.mall.provider.api.fallback.MemberServiceFallback;
import com.weixing.mall.provider.api.model.dto.MemberAgentBindDto;
import com.weixing.mall.provider.api.model.vo.AgentMemberVo;
import com.weixing.mall.provider.api.model.vo.MemberAuthVo;
import com.weixing.mall.provider.api.model.vo.MemberRpcVo;
import com.weixing.mall.provider.api.model.vo.PreOrderMemberVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.ribbon.FeignRibbonClientAutoConfiguration;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;

/**
 * @Author wx
 * @Date 2019/12/4 13:49
 * @Version 1.0
 */
@FeignClient(value = "mall-provider-uac", configuration = FeignRibbonClientAutoConfiguration.class, fallback = MemberServiceFallback.class)
public interface MemberServiceRpc {

    @GetMapping("api/member/selectById")
    Result<MemberRpcVo> selectById(@RequestParam(value = "id", required = false) Long id);

    @GetMapping("api/member/loadUserByUsername")
    Result<MemberAuthVo> loadUserByUsername(@RequestParam(value = "mobile") String mobile);

    @GetMapping("api/member/loadUserByMobile")
    Result<MemberAuthVo> loadUserByMobile(@RequestParam(value = "mobile") String mobile);

    @GetMapping("api/member/selectVoForPreOrder")
    Result<PreOrderMemberVo> selectVoForPreOrder(@RequestParam(value = "memberId") long memberId);

    @PostMapping("api/member/saveOrUpdateMember")
    Result saveOrUpdateMember(@RequestBody MemberAgentBindDto bindDto);

    @GetMapping("api/member/changAgentStatus")
    Result changAgentStatus(@RequestParam(value = "agentId") long agentId);

    @GetMapping("api/member/selectByAgentId")
    Result<MPage<AgentMemberVo>> selectByAgentId(@RequestParam(value = "agentId") long agentId,
                                                 @RequestParam(value = "currentPage") String currentPage,
                                                 @RequestParam(value = "pageSize") String pageSize);

    @GetMapping("api/member/loadUserByOpenId")
    Result<MemberAuthVo> loadUserByOpenId(@RequestParam(value = "openId") String openId);

    @GetMapping("api/member/updatePoint")
    Result updatePoint(@RequestParam(value = "memberId") long memberId,
                       @RequestParam(value = "point") Long point,
                       @RequestParam(value = "inOrOut") Integer inOrOut,
                       @RequestParam(value = "desp") String desp,
                       @RequestParam(value = "operator") Long operatorId);

    @PostMapping("api/member/createMember")
    Result createMember(@RequestBody MemberAgentBindDto bindDto);

    @GetMapping("api/member/bonusPointsHandle")
    Result bonusPointsHandle(@RequestParam(value = "memberId") Long memberId,
                             @RequestParam(value = "code") String code,
                             @RequestParam(value = "amount") BigDecimal amount,
                             @RequestParam(value = "operator") Long operatorId);

    @PostMapping("api/member/updateOpenId")
    Result updateOpenId(@RequestParam(value = "openId") String openId, @RequestParam(value = "mobile") String mobile);

    @PostMapping("api/member/removeBindAgent")
    Result removeBindAgent(@RequestParam(value = "agentId") Long agentId);

    @PostMapping("api/member/resetPwd")
    Result updatePwd(@RequestParam(value = "agentId") Long agentId, @RequestParam(value = "newPwd") String newPwd);

    @GetMapping("api/member/loadUserByXcxOpenId")
    Result<MemberAuthVo> loadUserByXcxOpenId(@RequestParam(value = "openId") String openId);
    @PostMapping("api/member/updateXcxOpenId")
    Result updateXcxOpenId(@RequestParam(value = "openId") String openid, @RequestParam(value = "mobile") String mobile);
    @PostMapping("api/member/xcxRegister")
    Result xcxRegister(@RequestParam(value = "openId") String openid,  @RequestParam(value = "mobile") String mobile);
    @GetMapping("api/member/loadAgentCid")
    Result<String> loadAgentCid(@RequestParam(value = "agentId", required = true) Long agentId);
}
